package nine_Chat;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) {
        BufferedWriter bw = null;
        BufferedReader br = null;
        try {
            Socket s =  new Socket("127.0.0.1", 9999);
            bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
            new ClientReaderThreadDuanToDuan(s).start();
            Scanner sc = new Scanner(System.in);
            System.out.print("Please input:");
            String str;
            while (!(str = sc.nextLine()).equals("886")) {
//                System.out.println(str);
//                System.out.println(str.equals("886"));
                bw.write(str);
                bw.newLine();
                bw.flush();
                System.out.print("Please input:");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (bw != null) {
                try {
                    bw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
